package com.grass.p019lv.game;

import android.content.Intent;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.bean.GameAccountBean;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.JsonParams;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.NetUtil;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.grass.p019lv.databinding.ActivityGameWithdrawBinding;
import com.grass.p019lv.game.bean.CustomTabEntity;
import com.grass.p019lv.game.bean.GameClassifyBean;
import com.grass.p019lv.game.bean.GameWithDrawBean;
import com.grass.p019lv.game.bean.WithDrawConfigBean;
import com.grass.p019lv.game.view.LoadingDialog;
import com.grass.p019lv.game.view.OnTabSelectListener;
import com.grass.p019lv.game.view.WithDrawDialog;
import com.gyf.immersionbar.ImmersionBar;
import java.util.ArrayList;
import java.util.List;

/* renamed from: com.grass.lv.game.GameWithdrawActivity */
public class GameWithdrawActivity extends BaseActivity<ActivityGameWithdrawBinding> {
    GameAccountBean info;
    private LoadingDialog loadingDialog;
    double maxMoney;
    private int payType;
    private ArrayList<CustomTabEntity> titleList = new ArrayList<>();
    private List<WithDrawConfigBean.WithDrawConfigData> withDrawConfigData;
    private WithDrawDialog withDrawDialog;
    private int withDrawMaxMoney;
    private int withDrawMinMoney;
    private double withDrawRate;

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return R.layout.activity_game_withdraw;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        this.loadingDialog = LoadingDialog.newInstance();
        this.withDrawDialog = WithDrawDialog.newInstance();
        ((ActivityGameWithdrawBinding) this.binding).tabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            /* class com.grass.p019lv.game.GameWithdrawActivity.C30291 */

            @Override // com.grass.p019lv.game.view.OnTabSelectListener
            public void onTabReselect(int i) {
            }

            @Override // com.grass.p019lv.game.view.OnTabSelectListener
            public void onTabSelect(int i) {
                if (GameWithdrawActivity.this.withDrawConfigData != null && GameWithdrawActivity.this.withDrawConfigData.size() > 0) {
                    GameWithdrawActivity gameWithdrawActivity = GameWithdrawActivity.this;
                    gameWithdrawActivity.payType = ((WithDrawConfigBean.WithDrawConfigData) gameWithdrawActivity.withDrawConfigData.get(i)).getPayType();
                    if (1 == GameWithdrawActivity.this.payType) {
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvAccountName.setText("支付寶賬戶");
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).edAccountNo.setHint("請輸入支付寶賬戶");
                    } else {
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvAccountName.setText("銀行卡賬戶");
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).edAccountNo.setHint("請輸入銀行卡賬戶");
                    }
                    for (int i2 = 0; i2 < GameWithdrawActivity.this.withDrawConfigData.size(); i2++) {
                        if (GameWithdrawActivity.this.payType == ((WithDrawConfigBean.WithDrawConfigData) GameWithdrawActivity.this.withDrawConfigData.get(i2)).getPayType()) {
                            TextView textView = ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvFee;
                            textView.setText("提取金額(收取" + (((WithDrawConfigBean.WithDrawConfigData) GameWithdrawActivity.this.withDrawConfigData.get(i2)).getRate() * 100.0d) + "%手續費)");
                            GameWithdrawActivity gameWithdrawActivity2 = GameWithdrawActivity.this;
                            gameWithdrawActivity2.withDrawMinMoney = ((WithDrawConfigBean.WithDrawConfigData) gameWithdrawActivity2.withDrawConfigData.get(i2)).getMinQuota();
                            GameWithdrawActivity gameWithdrawActivity3 = GameWithdrawActivity.this;
                            gameWithdrawActivity3.withDrawMaxMoney = ((WithDrawConfigBean.WithDrawConfigData) gameWithdrawActivity3.withDrawConfigData.get(i2)).getMaxQuota();
                            TextView textView2 = ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvWithdrawRange;
                            textView2.setText("满" + GameWithdrawActivity.this.withDrawMinMoney + "可提現，最高額度" + GameWithdrawActivity.this.withDrawMaxMoney);
                        }
                    }
                }
            }
        });
        this.withDrawDialog.setAnInterface(new WithDrawDialog.Interface() {
            /* class com.grass.p019lv.game.GameWithdrawActivity.C30302 */

            @Override // com.grass.p019lv.game.view.WithDrawDialog.Interface
            public void go2Order() {
                Intent intent = new Intent(GameWithdrawActivity.this, GameWithdrawHistoryActivity.class);
                intent.putExtra(Key.TXT, "提现记录");
                GameWithdrawActivity.this.startActivity(intent);
                GameWithdrawActivity.this.withDrawDialog.dismiss();
            }
        });
        ((ActivityGameWithdrawBinding) this.binding).imgBack.setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.GameWithdrawActivity.View$OnClickListenerC30313 */

            public void onClick(View view) {
                GameWithdrawActivity.this.finish();
            }
        });
        ((ActivityGameWithdrawBinding) this.binding).tvCommit.setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.GameWithdrawActivity.View$OnClickListenerC30324 */

            public void onClick(View view) {
                GameWithdrawActivity.this.doLoagic();
            }
        });
        ((ActivityGameWithdrawBinding) this.binding).tvWithdrawAll.setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.GameWithdrawActivity.View$OnClickListenerC30335 */

            public void onClick(View view) {
                EditText editText = ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).edMoney;
                editText.setText(((int) GameWithdrawActivity.this.maxMoney) + "");
            }
        });
        ((ActivityGameWithdrawBinding) this.binding).scrollView.setOnTouchListener(new View.OnTouchListener() {
            /* class com.grass.p019lv.game.GameWithdrawActivity.View$OnTouchListenerC30346 */

            public boolean onTouch(View view, MotionEvent motionEvent) {
                GameWithdrawActivity.this.onTouchEvent(motionEvent);
                return false;
            }
        });
        ((ActivityGameWithdrawBinding) this.binding).tvDetail.setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.GameWithdrawActivity.View$OnClickListenerC30357 */

            public void onClick(View view) {
                if (!GameWithdrawActivity.this.isOnClick()) {
                    Intent intent = new Intent(GameWithdrawActivity.this, GameWithdrawHistoryActivity.class);
                    intent.putExtra(Key.TXT, "提现记录");
                    GameWithdrawActivity.this.startActivity(intent);
                }
            }
        });
        getGameWithDrawConfig();
    }

    private void getGameWithDrawConfig() {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().getGameWithDrawConfig(), new HttpCallback<BaseRes<WithDrawConfigBean>>("getGameWithDrawConfig") {
            /* class com.grass.p019lv.game.GameWithdrawActivity.C30368 */

            public void onLvSuccess(BaseRes<WithDrawConfigBean> baseRes) {
                if (GameWithdrawActivity.this.binding != null && 200 == baseRes.getCode()) {
                    GameWithdrawActivity.this.withDrawConfigData = baseRes.getData().getData();
                    if (GameWithdrawActivity.this.withDrawConfigData == null || GameWithdrawActivity.this.withDrawConfigData.size() <= 0) {
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvCommit.setVisibility(8);
                        return;
                    }
                    for (int i = 0; i < GameWithdrawActivity.this.withDrawConfigData.size(); i++) {
                        if (1 == ((WithDrawConfigBean.WithDrawConfigData) GameWithdrawActivity.this.withDrawConfigData.get(i)).getPayType()) {
                            GameWithdrawActivity.this.titleList.add(new GameClassifyBean("提現到支付寶"));
                        }
                        if (2 == ((WithDrawConfigBean.WithDrawConfigData) GameWithdrawActivity.this.withDrawConfigData.get(i)).getPayType()) {
                            GameWithdrawActivity.this.titleList.add(new GameClassifyBean("提現到銀行卡"));
                        }
                    }
                    ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tabLayout.setTabData(GameWithdrawActivity.this.titleList);
                    ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tabLayout.setCurrentTab(0);
                    GameWithdrawActivity gameWithdrawActivity = GameWithdrawActivity.this;
                    gameWithdrawActivity.payType = ((WithDrawConfigBean.WithDrawConfigData) gameWithdrawActivity.withDrawConfigData.get(0)).getPayType();
                    if (1 == ((WithDrawConfigBean.WithDrawConfigData) GameWithdrawActivity.this.withDrawConfigData.get(0)).getPayType()) {
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvAccountName.setText("支付寶賬戶");
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).edAccountNo.setHint("請輸入支付寶賬戶");
                    } else {
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvAccountName.setText("銀行卡賬戶");
                        ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).edAccountNo.setHint("請輸入銀行卡賬戶");
                    }
                    TextView textView = ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvFee;
                    textView.setText("提取金額(收取" + (((WithDrawConfigBean.WithDrawConfigData) GameWithdrawActivity.this.withDrawConfigData.get(0)).getRate() * 100.0d) + "%手續費)");
                    GameWithdrawActivity gameWithdrawActivity2 = GameWithdrawActivity.this;
                    gameWithdrawActivity2.withDrawMinMoney = ((WithDrawConfigBean.WithDrawConfigData) gameWithdrawActivity2.withDrawConfigData.get(0)).getMinQuota();
                    GameWithdrawActivity gameWithdrawActivity3 = GameWithdrawActivity.this;
                    gameWithdrawActivity3.withDrawMaxMoney = ((WithDrawConfigBean.WithDrawConfigData) gameWithdrawActivity3.withDrawConfigData.get(0)).getMaxQuota();
                    TextView textView2 = ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).tvWithdrawRange;
                    textView2.setText("满" + GameWithdrawActivity.this.withDrawMinMoney + "可提現，最高額度" + GameWithdrawActivity.this.withDrawMaxMoney);
                }
            }
        });
    }

    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        super.onDestroy();
        if (this.loadingDialog != null) {
            this.loadingDialog = null;
        }
        HttpUtils.getInsatance().cancelTag("getGameWithDrawConfig");
        HttpUtils.getInsatance().cancelTag("withDraw");
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initData() {
        super.initData();
        GameAccountBean userGameAccount = SpUtils.getInstance().getUserGameAccount();
        this.info = userGameAccount;
        if (userGameAccount != null) {
            double balance = userGameAccount.getBalance();
            this.maxMoney = balance;
            TextView textView = ((ActivityGameWithdrawBinding) this.binding).tvMaxMoney;
            textView.setText(balance + "");
            TextView textView2 = ((ActivityGameWithdrawBinding) this.binding).tvWithdrawMaxMoney;
            textView2.setText(balance + "");
        }
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityGameWithdrawBinding) this.binding).toolbar).init();
    }

    public String getUserName() {
        return ((ActivityGameWithdrawBinding) this.binding).edName.getText().toString().trim();
    }

    public String getAccountNo() {
        return ((ActivityGameWithdrawBinding) this.binding).edAccountNo.getText().toString().trim();
    }

    public String getMoney() {
        return ((ActivityGameWithdrawBinding) this.binding).edMoney.getText().toString().trim();
    }

    public void doLoagic() {
        if (!NetUtil.isNetworkAvailable()) {
            ToastUtils.getInstance().showSigh("請檢查網路");
        } else if (TextUtils.isEmpty(getMoney())) {
            ToastUtils.getInstance().showSigh("請輸入提現金額");
        } else if (TextUtils.isEmpty(getUserName())) {
            ToastUtils.getInstance().showSigh("請輸入姓名");
        } else if (TextUtils.isEmpty(getAccountNo())) {
            ToastUtils.getInstance().showSigh(this.payType == 1 ? "請輸入支付寶賬戶" : "請輸入銀行卡賬號");
        } else {
            try {
                int parseInt = Integer.parseInt(getMoney());
                if (((double) parseInt) > this.maxMoney) {
                    ToastUtils.getInstance().showSigh("超過提現餘額,請重新輸入");
                } else if (parseInt < this.withDrawMinMoney || parseInt > this.withDrawMaxMoney) {
                    ToastUtils.getInstance().showSigh("提現金額在" + this.withDrawMinMoney + "到" + this.withDrawMaxMoney + "之間");
                } else {
                    this.loadingDialog.show(getSupportFragmentManager(), "loadingDialog");
                    final String str = parseInt + "";
                    HttpUtils.getInsatance().post(UrlManager.getInsatance().gameWithDraw(), JsonParams.build().add("accountNo", getAccountNo()).add("money", str).add("payType", Integer.valueOf(this.payType)).add("purType", 1).add("receiptName", getUserName()).commit(), new HttpCallback<BaseRes<GameWithDrawBean>>("withDraw") {
                        /* class com.grass.p019lv.game.GameWithdrawActivity.C30379 */

                        public void onLvSuccess(BaseRes<GameWithDrawBean> baseRes) {
                            if (GameWithdrawActivity.this.loadingDialog != null) {
                                GameWithdrawActivity.this.loadingDialog.dismiss();
                            }
                            if (200 != baseRes.getCode()) {
                                ToastUtils.getInstance().showSigh(baseRes.getMsg());
                            } else if (baseRes.getData().isSuccess()) {
                                GameAccountBean gameAccountBean = GameWithdrawActivity.this.info;
                                double balance = GameWithdrawActivity.this.info.getBalance();
                                double parseInt = (double) Integer.parseInt(str);
                                Double.isNaN(parseInt);
                                gameAccountBean.setBalance(balance - parseInt);
                                SpUtils.getInstance().setUserGameAccount(GameWithdrawActivity.this.info);
                                GameWithdrawActivity.this.initData();
                                GameWithdrawActivity.this.withDrawDialog.setData(GameWithdrawActivity.this.getMoney());
                                GameWithdrawActivity.this.withDrawDialog.show(GameWithdrawActivity.this.getSupportFragmentManager(), "withDrawDialog");
                                ((ActivityGameWithdrawBinding) GameWithdrawActivity.this.binding).edMoney.setText("");
                            } else {
                                ToastUtils.getInstance().showSigh(baseRes.getMsg());
                            }
                        }
                    });
                }
            } catch (Exception unused) {
                ToastUtils.getInstance().showSigh("提現金額必須為整數");
            }
        }
    }
}
